//
//  StatusCellBottonView.swift
//  Weibo
//
//  Created by 冯童童 on 16/1/18.
//  Copyright © 2016年 冯童童. All rights reserved.
//

import UIKit
import SnapKit

class StatusCellBottonView: UIView {
    
    @objc private func commentBtnDidClick() {
        
        let temp = TempViewController()
        temp.hidesBottomBarWhenPushed = true
        navController()?.pushViewController(temp, animated: true)
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI(){
        backgroundColor = UIColor.whiteColor()
        addSubview(retweetedBtn)
        addSubview(commentBtn)
        addSubview(likeBtn)
        
        retweetedBtn.snp_makeConstraints { (make) -> Void in
            make.top.left.bottom.equalTo(self)
        }
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.top.bottom.equalTo(self)
            make.width.equalTo(retweetedBtn.snp_width)
        }

        likeBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.top.bottom.equalTo(self)
            make.right.equalTo(self.snp_right)
            make.width.equalTo(commentBtn.snp_width)


        }
        
        let sepView1 = lineView()
        let sepView2 = lineView()
        addSubview(sepView1)
        addSubview(sepView2)
        
        let w : CGFloat = 0.5
        let scale : CGFloat = 0.4
        sepView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
            make.width.equalTo(w)
        }
        sepView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
            make.width.equalTo(w)
        }

        commentBtn.addTarget(self, action: "commentBtnDidClick", forControlEvents: .TouchUpInside)
    }
    
    private func lineView() -> UIView {
        
        let v = UIView()
        v.backgroundColor = UIColor.lightGrayColor()
        return v
    }
    
    private lazy var retweetedBtn : UIButton = UIButton(title: "转发", fontSize: 10, color: UIColor.darkGrayColor(), backImageName: nil, imageName: "timeline_icon_retweet")
    private lazy var commentBtn : UIButton = UIButton(title: "评论", fontSize: 10, color: UIColor.darkGrayColor(), backImageName: nil, imageName: "timeline_icon_comment")

    private lazy var likeBtn : UIButton = UIButton(title: "点赞", fontSize: 10, color: UIColor.darkGrayColor(), backImageName: nil, imageName: "timeline_icon_unlike")

}
